package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.BsBorrcertificateEntity;
import io.renren.modules.app.service.BsBorrcertificateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;





/**
 * 借阅证表
 *
 * @author zwl
 * @email ${email}
 * @date 2024-01-02 10:35:02
 */
@RestController
@RequestMapping("bs_borrcertificate/bsborrcertificate")
public class BsBorrcertificateController {
    @Autowired
    private BsBorrcertificateService bsBorrcertificateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bs_borrcertificate:bsborrcertificate:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bsBorrcertificateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("bs_borrcertificate:bsborrcertificate:info")
    public R info(@PathVariable("id") Integer id){
		BsBorrcertificateEntity bsBorrcertificate = bsBorrcertificateService.getById(id);

        return R.ok().put("bsBorrcertificate", bsBorrcertificate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bs_borrcertificate:bsborrcertificate:save")
    public R save(@RequestBody BsBorrcertificateEntity bsBorrcertificate){
        bsBorrcertificate.setCreateTime(new Date());
        bsBorrcertificate.setUpdateTime(new Date());
        bsBorrcertificateService.saveBsBorrcertificateEntity(bsBorrcertificate);
//		bsBorrcertificateService.save(bsBorrcertificate);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bs_borrcertificate:bsborrcertificate:update")
    public R update(@RequestBody BsBorrcertificateEntity bsBorrcertificate){
        bsBorrcertificate.setUpdateTime(new Date());
        bsBorrcertificateService.updateBsBorrcertificateEntityById(bsBorrcertificate);
//		bsBorrcertificateService.updateById(bsBorrcertificate);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bs_borrcertificate:bsborrcertificate:delete")
    public R delete(@RequestBody Integer[] ids){
		bsBorrcertificateService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 批量启用接口
     */
    @RequestMapping("/startBatch")
    public R startBatch(@RequestBody Integer[] ids){
        bsBorrcertificateService.startBatch(ids);
        return R.ok();
    }

    /**
     * 批量禁用接口
     * @param ids
     * @return
     */
    @RequestMapping("/stopBatch")
    public R stopBatch(@RequestBody Integer[] ids){
        bsBorrcertificateService.stopBatch(ids);
        return R.ok();
    }

}
